<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>
            <?php echo $title; ?>-<?php echo C('SITE_NAME'); ?>
        </title>
        <link rel="stylesheet" href="//at.alicdn.com/t/font_001z27klwvobt9.css">
        <link rel="stylesheet" href="/P201606/bbs/Public/css/layui.css">
        <link rel="stylesheet" href="/P201606/bbs/Public/css/global.css">
        <script src="/P201606/bbs/Public/layui.js"></script>
        <script type="text/javascript" src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
    </head>
    
    <body>
        <div class="header">
            <div class="main">
                <a class="logo" href="<?php echo U('home/index/index');?>" title="Fly">
                    Fly社区
                </a>
                <div class="nav">
                    <a href="/<?php echo U('home/index/index');?>">
                        <i class="iconfont icon-wenda">
                        </i>
                        问答
                    </a>
                    <a href="<?php echo U('home/index/index');?>">
                        <i class="iconfont icon-iconmingxinganli" style="top: 2px;">
                        </i>
                        案例
                    </a>
                    <a href="<?php echo U('home/index/index');?>">
                        <i class="iconfont icon-ui">
                        </i>
                        框架
                    </a>
                </div>
                <div class="nav-user">
                    <?php if(isset($_SESSION['nikename'])){ ?>

                    <a class="avatar" href="<?php echo U('home/u/index');?>">
                        <img class="face" src="/P201606/bbs/<?php echo $_SESSION['face'] ?>">
                        <cite>
                            <?php echo $_SESSION['nikename'] ?>
                        </cite>
                    </a>
                    <div class="nav">
                        <a href="<?php echo U('home/set/set');?>">
                            <i class="iconfont icon-shezhi">
                            </i>
                            设置
                        </a>
                        <a href="<?php echo U('home/login/loginout');?>">
                            <i class="iconfont icon-tuichu" style="top: 0; font-size: 22px;">
                            </i>
                            退了
                        </a>
                    </div>

                    <?php }else{ ?>

                    <a class="unlogin" href="<?php echo U('home/login/index');?>">
                        <i class="iconfont icon-touxiang">
                        </i>
                    </a>
                    <span>
                        <a href="<?php echo U('home/login/index');?>">
                            登入
                        </a>
                        <a href="<?php echo U('home/reg/index');?>">
                            注册
                        </a>
                    </span>
                    <p class="out-login">
                        <?php if(C('IS_QQLOGIN')){ ?>

                         
                        <a href="<?php echo U('home/login/qqlogin');?>" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})"
                        class="iconfont icon-qq" title="QQ登入">
                        </a>

                        <?php  } ?>
                        <a href="http://fly.layui.com:8098/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})"
                        class="iconfont icon-weibo" title="微博登入">
                        </a>
                    </p>

                    <?php } ?>
                </div>
            </div>
        </div>
        <div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
            <h1>
                <?php echo $q['title'] ?>
            </h1>
            <div class="fly-tip fly-detail-hint" data-id="6503">
                <span>
                    <?php echo $q['status'] ?>
                </span>
                <div class="fly-list-hint">
                    <i class="iconfont" title="回答">
                        
                    </i>
                    <?php echo $q['answer_num'] ?>
                    <i class="iconfont" title="人气">
                        
                    </i>
                    <?php echo $q['view_num'] ?>
                </div>
            </div>
            <div class="detail-about">
                <a class="jie-user" href="">
                    <img src="/P201606/bbs/<?php echo $q['face'] ?>" alt="心怀">
                    <cite>
                        <?php echo $q['nikename'] ?>
                        <em>
                            发布于19小时前
                        </em>
                    </cite>
                </a>
                <div class="detail-hits" data-id="6503">
                    <span style="color:#FF7200">
                        悬赏：<?php echo $q['kiss'] ?>飞吻
                    </span>
                </div>
            </div>
            <div class="detail-body photos" style="margin-bottom: 20px;">
                <?php echo htmlspecialchars_decode($q['content']) ?>
            </div>
            <a name="comment">
            </a>
            <h2 class="page-title">
                热忱回答
                <span>
                    （
                    <em id="jiedaCount">
                        <?php echo count($a) ?>
                    </em>
                    ）
                </span>
            </h2>
            <ul class="jieda photos" id="jieda">
                <?php foreach ($a as $v) { ?>
                
                <li data-id="22999">
                    <a name="item-1483513264795">
                    </a>
                    <div class="detail-about detail-about-reply">
                        <a class="jie-user" href="<?php echo U('home/u/index',array('uid'=>$v['uid']));?>">
                            <img src="/P201606/bbs/<?php echo $v['face'] ?>"
                            alt="放逐之魚" layer-index="0">
                            <cite>
                                <i>
                                    <?php echo $v['nikename'] ?>
                                </i>
                            </cite>
                        </a>
                        <div class="detail-hits">
                            <span>
                                <?php echo getFormate($v['create_time']) ?>
                            </span>
                        </div>
                    </div>
                    <div class="detail-body jieda-body">
                       <?php echo htmlspecialchars_decode($v['content']) ?>
                    </div>
                    <div class="jieda-reply" nikename="<?php echo $v['nikename'] ?>">
                        <span class="jieda-zan " type="zan">
                            <i class="iconfont icon-zan">
                            </i>
                            <em>
                                <?php echo $v['zan'] ?>
                            </em>
                        </span>
                        <span type="reply">
                            <i class="iconfont icon-svgmoban53">
                            </i>
                            回复
                        </span>
                    </div>
                </li>
                <?php } ?>
            </ul>
            <div class="layui-form layui-form-pane">
                <form action="/jie/reply/" method="post">
                    <div class="layui-form-item layui-form-text">
                        <div class="layui-input-block">
                            <textarea id="L_content" name="content" required lay-verify="content"
                            placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <input type="hidden" name="qid" value="<?php echo $q['id'] ?>">
                        <button class="layui-btn" lay-filter="answer" lay-submit>
                            提交回答
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="edge">
        <h3 class="page-title">
            最近热帖
        </h3>
        <ol class="fly-list-one">
            <li>
                <a href="/jie/6454.html">
                    基于Fly社区模板的问答社区正式开源啦，PHP做的。
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    1635
                </span>
            </li>
        </ol>
        <h3 class="page-title">
            近期热议
        </h3>
        <ol class="fly-list-one">
            <li>
                <a href="/jie/6454.html">
                    基于Fly社区模板的问答社区正式开源啦，PHP做的。
                </a>
                <span>
                    <i class="iconfont">
                        
                    </i>
                    18
                </span>
            </li>
        </ol>
    </div>
</div>
<script>
layui.use(['form', 'layedit'], function(){
  form = layui.form()
  ,layer = layui.layer
  ,layedit = layui.layedit;

    layedit.set({
      uploadImage: {
        url: "<?php echo U('home/question/upload');?>" //接口url
        ,type: 'post' //默认post
      }
    })
  
    //创建一个编辑器
    editIndex = layedit.build('L_content');

    //自定义验证规则
      form.verify({
        content: function(obj){
          content = layedit.getContent(editIndex);
          if(content.length<20){
            return "内容必须大于20个字符";
          }else{
            layedit.sync(editIndex);
          }
        }
      });

    $('.jieda-reply').click(function(event) {
        content = layedit.getText(editIndex);
        nikename ='@';
        nikename += $(this).attr('nikename');
        alert(content);
        nikename +=content;
        // nikename +=content;
        alert(nikename);
        $('#L_content').text(nikename);

        editIndex = layedit.build('L_content');

    });
    
 
  //自定义验证规则
  //监听提交
  form.on('submit(answer)', function(data){
    console.log(data);
    $.ajax({
        url: "<?php echo U('home/answer/post');?>",
        type: 'POST',
        dataType: 'json',
        data: data.field,
    })
    .done(function(response) {
        console.log(response);
        if(response['error']==0){

            layer.msg(response.info, {icon: 6});

            str = '<li data-id="22999"><a name="item-1483513264795"></a><div class="detail-about detail-about-reply"><a class="jie-user"href="/P201606/bbs/index.php/home/u/index/uid/4"><img src="/P201606/bbs/Public/images/face/face_1.jpg"alt="放逐之魚"layer-index="0"><cite><i>'+response.data.nikename+'</i></cite></a><div class="detail-hits"><span>'+response.data.create_time+'</span></div></div><div class="detail-body jieda-body">'+response.data.content+'</div><div class="jieda-reply"><span class="jieda-zan "type="zan"><i class="iconfont icon-zan"></i><em>'+response.data.zan+'</em></span><span type="reply"><i class="iconfont icon-svgmoban53"></i>回复</span></div></li>';

            $('#jieda').append(str);

        }else{
            layer.msg(response.info, {icon: 5});
        }
        
    })
    .fail(function() {
        layer.msg("数据传输失败", {icon: 5});
    })
    
    return false;
  });

    
  
  
});
</script>
        <div class="footer">
            <p>
                <a href="http://fly.layui.com/">
                    Fly社区
                </a>
                2016 &copy;
                <a href="http://www.layui.com/">
                    layui.com
                </a>
            </p>
            <p>
                <a href="http://fly.layui.com/jie/3147.html" target="_blank">
                    产品授权
                </a>
                <a href="http://fly.layui.com/jie/4536.html" target="_blank">
                    获取Fly社区模版
                </a>
                <a href="http://fly.layui.com/jie/2461.html" target="_blank">
                    微信公众号
                </a>
            </p>
        </div>
        
    </body>

</html>